home *** CD-ROM | disk | FTP | other *** search
- 10 REM N1ii May 9, 1995 V1.0
- 15 '2 CHANNEL VOLT METER VERSION
- 20 REM This software makes 2 A/D conversions and
- 30 REM reads them out serially into a parallel
- 40 REM printer port on a PC
- 50 REM ***********************
- 60 REM initial setup
- 70 SCREEN 0 'pick 80 column text mode
- 80 COLOR 2, 0 'I like green on black
- 90 CLS 'First clear the screen
- 100 CLEAR 'Then clear all variables
- 105 PORTO = &H378 'Define output port
- 110 DEFINT A-O 'all varib. starting w/ A-O are integers
- 120 TFIX0 = 4.9 / 255 'scale factor for channel 0
- 130 TFIX1 = 4.9 / 255 'scale factor for channel 1
- 135 NOMORE$ = "" 'set varible to blank
- 200 '************************* This is the start of the program
- 210 WHILE NOMORE$ = ""
- 220 NOMORE$ = INKEY$ 'Push any key to quit
- 230 OUT PORTO,10 'Data bit 3, Pin 5 (CS) goes high
- 240 'and data bit 1, pin 3 (DI) goes high
- 250 OUT PORTO,2 'CS goes low and DI stays high
- 260 GOSUB 1000 'first clock pulse
- 270 'DI stays high for single ended conversion
- 280 GOSUB 1000 'second clock pulse
- 290 OUT PORTO,0 'now select input channel 0 - DI low
- 300 GOSUB 1000 'third clock pulse
- 310 'now the data read-in starts
- 320 FOR CLK = 7 TO 0 STEP -1 'going to generate 8 clocks
- 330 GOSUB 1000
- 340 INBIT = INP(PORTO+1) 'going to look at pin 10 (2^7+2^6+...)
- 350 ' after each clock
- 360 IF INBIT < 125 THEN INVAL = 1 ELSE INVAL = 0'if (not ack) is low then
- 370 ' the input bit is a one
- 380 TOTAL0 = TOTAL0 + INVAL * (2 ^ CLK)'form decimal number from INBITs
- 390 NEXT CLK 'next clk to get next inbit
- 400 TOTAL0 = TFIX0 * TOTAL0 'fix calibration Channel 0
- 410 FOR CLK = 0 TO 7 STEP 1 '8 more clocks needed
- 420 GOSUB 1000
- 430 NEXT CLK
- 440 GOSUB 1000 'couple more clocks with CS low
- 450 GOSUB 1000
- 460 OUT PORTO,10 'CS goes high (conversions over)
- 470 GOSUB 1000 'couple more clocks with CS high
- 480 GOSUB 1000 ' clears internal registers
- 500 REM NOW RUN THE PROGRAM AGAIN FOR CHANNEL 1
- 510 OUT PORTO,10 'Data bit 3, Pin 5 (CS) goes high
- 520 'and data bit 1, pin 3 (DI) goes high
- 530 OUT PORTO,2 'CS goes low and DI stays high
- 540 GOSUB 1000 'first clock pulse
- 550 'DI stays high for single ended conversion
- 560 GOSUB 1000 'second clock pulse
- 570 OUT PORTO,2 'now select input channel 1 - DI HIGH
- 580 GOSUB 1000 'third clock pulse
- 590 'now the data read-in starts
- 600 FOR CLK = 7 TO 0 STEP -1 'going to generate 8 clocks
- 610 GOSUB 1000
- 620 INBIT = INP(PORTO+1) 'going to look at pin 10 (2^7+2^6+...)
- 630 ' after each clock
- 640 IF INBIT < 125 THEN INVAL = 1 ELSE INVAL = 0'if (not ack) is low then
- 650 ' the input bit is a one
- 660 TOTAL1 = TOTAL1 + INVAL * (2 ^ CLK)'form decimal number from INBITs
- 670 NEXT CLK 'next clk to get next inbit
- 680 TOTAL1 = TFIX1 * TOTAL1 'fix calibration Channel 1
- 690 FOR CLK = 0 TO 7 STEP 1 '8 more clocks needed
- 700 GOSUB 1000
- 710 NEXT CLK
- 720 GOSUB 1000 'couple more clocks with CS low
- 730 GOSUB 1000
- 740 OUT PORTO,10 'CS goes high (conversions over)
- 750 GOSUB 1000 'couple more clocks with CS high
- 760 GOSUB 1000 ' clears internal registers
- 780 GOSUB 2000 'now process the output for display
- 790 WEND
- 800 END
- 1000 'clock subroutine
- 1010 CD = 1 'set clock width
- 1020 OUT (PORTO+2),0 'set pin 14 (autolf (not)) high
- 1030 ' this sets clock high
- 1040 FOR CW = 0 TO CD STEP 1: NEXT CW 'set clock pulse width
- 1050 OUT (PORTO+2),2 'set pin 14 low (end of clock pulse)
- 1060 RETURN
- 2000 REM subroutine for displaying the results
- 2010 REM This space used for processing TOTAL0 and TOTAL1
- 2020 REM the outputs of the two measurment channels
- 2030 LOCATE 1, 1 'the next few steps prints the
- 2040 PRINT "Channel 0 =" 'outputs of channel 0 and 1
- 2050 LOCATE 2, 4
- 2060 PRINT USING "##.##"; TOTAL0
- 2070 LOCATE 1, 30
- 2080 PRINT "Channel 1= "
- 2090 LOCATE 2, 34
- 2100 PRINT USING "##.##"; TOTAL1
- 2110 LOCATE 5, 1
- 2120 TDELTA = ABS(TOTAL0 - TOTAL1)
- 2130 IF TDELTA < .001 THEN GOTO 2190
- 2140 PRINT "SWR = "
- 2150 SWR = ABS((TOTAL0 + TOTAL1) / (TOTAL0 - TOTAL1))
- 2160 LOCATE 6, 4
- 2170 PRINT USING "###########.##"; SWR
- 2180 RETURN
- 2190 LOCATE 6, 4
- 2200 PRINT "SWR NOT VALID!"
- 2210 RETURN